package pub.cleangao.mybatis.config;


import lombok.Getter;
import pub.cleangao.mybatis.runtime.Mode;
import pub.cleangao.mybatis.structure.OrmConfig;
import java.util.Properties;

@Getter
public class EnhanceProperties {

    /**
     * 代码模块(此项目中)的根路径包
     */
    protected String moduleRootPackage;

    /**
     * 数据表映射实体类
     */
    protected String entityPackage;

    /**
     * 数据表操作mapper
     */
    protected String mapperPackage;

    /**
     * 是否扫描根路径
     */
    protected boolean scanRoot = false;

    /**
     * 建表SQL目录
     */
    protected String cleavageDdlRoot;

    /**
     * 字段与列名对应是否驼峰与下划线互转
     */
    protected boolean fieldCamel2Underline = true;





    public EnhanceProperties(Properties properties) {
        this.scanRoot = "true".equalsIgnoreCase(properties.getProperty("mybatis.enhance.scan-root", "false").trim());
        this.moduleRootPackage = properties.getProperty("module.root-package", "").trim();
        //
        this.entityPackage = properties.getProperty("module.orm.entity-package", "").trim();
        this.mapperPackage = properties.getProperty("module.orm.mapper-package", "").trim();
        this.cleavageDdlRoot = properties.getProperty("mybatis.enhance.cleavage.table-ddl", "").trim();
        Mode.DEBUG = "true".equalsIgnoreCase(properties.getProperty("mybatis.enhance.mode.debug", "false").trim());
        this.fieldCamel2Underline = "true".equalsIgnoreCase(properties.getProperty("mybatis.enhance.convert.camel2underline", "true").trim());
        OrmConfig.camel2underline = this.fieldCamel2Underline;
    }
}
